package com.jxl.charactersheet.vo.inventory
{
	import com.jxl.dnd.equipment.Item;
	import com.jxl.dnd.equipment.ItemEffect;

	public class WearableItem extends Item
	{
		
		public static const ITEM:uint 				= 0;
		public static const HEAD:uint 				= 1;
		public static const EYES:uint				= 2;
		public static const NECK:uint				= 3;
		public static const SHOULDERS:uint			= 4;
		public static const RING_LEFT:uint			= 5;
		public static const RING_RIGHT:uint			= 6;
		public static const HANDS:uint				= 7;
		public static const ARMS:uint				= 8;
		public static const BODY:uint				= 9;
		public static const TORSO:uint				= 10;
		public static const WAIST:uint				= 11;
		public static const FEET:uint				= 12;
		
		
		public var type:uint = 0;
		
		public function WearableItem(name:String="", 
									  cost:Number=0, 
									  weight:Number=0, 
									  preparationTime:Number=0,
									  itemEffect:ItemEffect=null,
									  thumbnail:String="",
									  type:uint=0):void
		{
			super(name, cost, weight, preparationTime, itemEffect, thumbnail);
			
			this.type = type;
		}
		
		public function toTypeString():String
		{
			var str:String = "";
			switch(type)
			{
				case 0:		str = "item";			break;
				
				case 1:		str = "head";			break;
				
				case 2:		str = "eyes";			break;
				
				case 3:		str = "neck";			break;
				
				case 4:		str = "shoulders";		break;
				
				case 5:		str = "ringLeft";		break;
				
				case 6:		str = "ringRight";		break;
				
				case 7:		str = "hands";			break;
				
				case 8:		str = "arms";			break;
				
				case 9:		str = "body";			break;
				
				case 10:	str = "torso";			break;
				
				case 11:	str = "waist";			break;
				
				case 12:	str = "feet";			break;
			}
			return str;
		}
		
		public override function toXML():XML
		{
			var wXML:XML = super.toXML();
			wXML.@type = "wearableitem";
			wXML.appendChild(<type>{type}</type>);
			return wXML;
		}
		
		public override function buildFromXML(xml:XML):void
		{
			super.buildFromXML(xml);
			
			type 			= parseInt(xml.type);
			thumbnail		= String(xml.thumbnail.text());
		}
		
		
		
	}
}
	